package airthmetic.exercise.sort.cmp;


import airthmetic.exercise.sort.Sort;

public class SelectionSort<T extends Comparable<T>> extends Sort<T> {

    @Override
    protected void sort() {
        for (int i = array.length - 1; i > 0; i--) {
            int maxIndex = 0;
            for (int j = 1; j <= i; j++) {
                if (cmp(maxIndex, j) <= 0) {
                    maxIndex = j;
                }
            }
            swap(maxIndex, i);
        }
    }

}
